<?php

class Zhishidi_Dailydeals_Block_Adminhtml_Dailydeals_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {

    public function __construct() {
        parent::__construct();

        $this->_objectId = 'id';

        $this->_blockGroup = 'zhishidi_dailydeals';
        $this->_controller = 'adminhtml_dailydeals';


        $this->_updateButton('save', 'label', Mage::helper('zhishidi_dailydeals')->__('Save Deal'));

        if ($this->getRequest()->getParam('id')) {
            $this->_updateButton('delete', 'label', Mage::helper('zhishidi_dailydeals')->__('Delete Deal'));
        } else {
            $this->removeButton('delete');
        }
        $this->_addButton('saveandcontinue', array(
            'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
            'onclick' => 'saveAndContinueEdit()',
            'class' => 'save',
                ), -100);

        $this->_formScripts[] = "
            function saveAndContinueEdit(){
                editForm.submit($('edit_form').action+'back/edit/');
            }
        ";
    }

    public function getHeaderText() {
        if (Mage::registry('dailydeals_data') && Mage::registry('dailydeals_data')->getId()) {
            return Mage::helper('zhishidi_dailydeals')->__("Edit Deal '%s'", $this->htmlEscape(Mage::registry('dailydeals_data')->getId()));
        } else {
            return Mage::helper('zhishidi_dailydeals')->__('Add Daily Deal');
        }
    }

}